package com.asiainfo.smsstationphone.util;

import com.asiainfo.smsstationphone.R;

import android.content.Context;
import android.graphics.Color;
import android.os.Vibrator;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.EditText;
import android.widget.TextView;

public class ActivityUtils
{
	private static final int VIBRATE_DURATION = 100;
	public static void viewShake(final View et) {
		//et.setHintTextColor(Color.RED);
		Animation shake = AnimationUtils.loadAnimation(et.getContext(), R.anim.shake);
		et.startAnimation(shake);
		et.requestFocus();
	}
	
	public  static void vibrate(Context ctt)
	{
		Vibrator vibrator = (Vibrator) ctt.getSystemService(Context.VIBRATOR_SERVICE);
		vibrator.vibrate(VIBRATE_DURATION);
	}
	
	public  static void vibrate(Context ctt,long duration)
	{
		Vibrator vibrator = (Vibrator) ctt.getSystemService(Context.VIBRATOR_SERVICE);
		vibrator.vibrate(duration);
	}
	
	public static void editTextShake(final TextView et) {
		et.setHintTextColor(Color.RED);
		Animation shake = AnimationUtils.loadAnimation(et.getContext(), R.anim.shake);
		et.startAnimation(shake);
		et.requestFocus();
	}
	
    public static View.OnClickListener editTextTipOnClickListener(final EditText et)
    {
		return new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				et.setHintTextColor(Color.GRAY);
			}
		};
    }
	
}
